using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ASP_TF2LogParser.UserControls
{
    public partial class WeaponTop25 : System.Web.UI.UserControl
    {
        protected void Page_Load( object sender, EventArgs e )
        {

        }

        public string GetHeadshotPercentage( string kills, string playerId )
        {
            // FIX THIS

            string headshotPercentage = string.Empty;

            int classKillCount = 1; //Convert.ToInt32( LogParser.DA.ClassModel.GetClassHeadshotCountSelect( Convert.ToInt32( classId ) ) );

            double headshotPerc = ( ( double ) ( Convert.ToDouble( classKillCount ) ) / ( Convert.ToDouble( kills ) ) ) * 100;
            headshotPercentage = headshotPerc.ToString();

            headshotPercentage = string.Format( "{0:0.00}", headshotPerc );

            if ( headshotPercentage == "NaN" )
                headshotPercentage = "0.00";

            return headshotPercentage;
        }

        public string GetKillDeathRatio( int kills, int deaths )
        {
            if ( deaths == 0 )
                deaths = 1;  // NaN issue fix

            double totalRatio = ( ( ( double ) ( kills ) ) / ( ( double ) deaths ) );
            string ratio = string.Format( "{0:0.00}", totalRatio );

            return ratio;
        }


        public string GenerateUrl( string playerName, string playerId )
        {

            string returnUrl = "";

            returnUrl = "<a href='Player.aspx?playerId=" + playerId + "'>" + playerName + "</a>";

            return returnUrl;


        }


    }
}